//
//  NSObject+KHDBTable.h
//  AMapDemo-iOS
//
//  Created by apang on 2017/12/20.
//  Copyright © 2017年 men.apang.AMapDemo-iOS. All rights reserved.

#import <Foundation/Foundation.h>
#import "KHDBHelper.h"
#define primaryId   @"sort"

@interface NSObject (KHDBTable)
@property (nonatomic, assign, readonly) NSInteger sort;
@property (nonatomic, copy) NSString * tableName;
+ (BOOL)isExistsInTable:(NSString *)tableName;
+ (BOOL)createTable:(NSString *)tableName;
+ (BOOL)updateTable:(NSString *)tableName;

- (BOOL)save;
+ (BOOL)saveObjects:(NSArray *)objects;
- (BOOL)deleteObject;
+ (BOOL)deleteObjects:(NSArray *)objects;
+ (BOOL)deleteObjectsWithPredicate:(NSString *)predicate;
+ (BOOL)deleteObjectsWithFormat:(NSString *)format, ...;
- (BOOL)update;
+ (BOOL)updateObjects:(NSArray *)objects;
+ (BOOL)updateObjectsWithFormat:(NSString *)format, ...;
+ (NSArray *)inquiryAll:(NSString *)tableName;
+ (NSArray *)inquiryWithPrimaryKey:(NSInteger)primaryKey;
+ (NSArray *)inquiryWithPredicate:(NSString *)predicate;
+ (NSArray *)inquiryWithFormat:(NSString *)format, ...;
@end

@protocol KHDBTable <NSObject>
@optional
+ (NSArray *)ignorePropertyNams;
@end
